package com.cskaoyan.market.service;

import com.cskaoyan.market.db.domain.MarketLog;
import com.cskaoyan.market.db.domain.MarketLogExample;
import com.cskaoyan.market.db.mapper.MarketLogMapper;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service

public class MarketLogServiceImpl implements MarketLogService {
   @Autowired
    MarketLogMapper logMapper;
    @Override
    public List<MarketLog> list(Integer page, Integer limit, String sort, String order,String name) {
        MarketLogExample marketLogExample = new MarketLogExample();
        MarketLogExample.Criteria criteria = marketLogExample.createCriteria();
        marketLogExample.setOrderByClause(sort+" "+order);
        if(!StringUtils.isEmpty(name)){
            criteria.andAdminEqualTo(name);
        }
        PageHelper.startPage(page,limit);
        List<MarketLog> marketLogList = logMapper.selectByExampleSelective(marketLogExample, MarketLog.Column.id, MarketLog.Column.admin,
                MarketLog.Column.ip, MarketLog.Column.type, MarketLog.Column.action, MarketLog.Column.status, MarketLog.Column.result,
                MarketLog.Column.comment, MarketLog.Column.addTime, MarketLog.Column.updateTime, MarketLog.Column.deleted);
        return marketLogList;
    }
}
